<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>mfile2sci</title>
  </head>
  <body bgcolor="#FFFFFF">
    <center>Scilab Function</center>
    <div align="right">Last update : 30/03/2004</div>
    <p>
      <b>mfile2sci</b> -  Matlab M-file to Scilab conversion function</p>
    <h3>
      <font color="blue">Calling Sequence</font>
    </h3>
    <dl>
      <dd>
        <tt>mfile2sci([M-file-path [,result-path [,Recmode [,only-double [,verbose-mode [,prettyprint]]]]]])  </tt>
      </dd>
    </dl>
    <h3>
      <font color="blue">Parameters</font>
    </h3>
    <ul>
      <li>
        <tt>
          <b>M-file-path</b>
        </tt>: a character string which gives the path of Matlab M-file to convert</li>
      <li>
        <tt>
          <b>result-path</b>
        </tt>: a character string which gives the directory where the result has to be written. Default value is current directory.</li>
      <li>
        <tt>
          <b>Recmode</b>
        </tt>: Boolean flag, used by translatepaths function for recursive conversion. Must be %F to convert a single mfile. Default value : %f</li>
      <li>
        <tt>
          <b>only-double</b>
        </tt>: Boolean flag, if %T mfile2sci considers that numerical function have been used only with numerical data (no Scilab overloading function is needed). Default value: %F</li>
      <li>
        <tt>
          <b>verbose-mode</b>
        </tt>:  display information mode<ul>
          <li>
            <tt>
              <b>0</b>
            </tt>: no information displayed</li>
          <li>
            <tt>
              <b>1</b>
            </tt>: information written as comment is resulting SCI-file</li>
          <li>
            <tt>
              <b>2</b>
            </tt>: information written as comment is resulting SCI-file and in logfile</li>
          <li>
            <tt>
              <b>3</b>
            </tt>: information written as comment is resulting SCI-file, in logfile and displayed in Scilab window</li>
        </ul>
      </li>
      <li>
        <tt>
          <b>prettyprint</b>
        </tt>: Boolean flag, if %T generated code is beautified. Default value: %F</li>
    </ul>
    <h3>
      <font color="blue">Description</font>
    </h3>
    <p>
    M2SCI (and particularly mfile2sci) is Matlab M-file to Scilab function conversion tools. It
    tries whenever possible to replace call to Matlab functions by the
    equivalent Scilab primitives and functions.
  </p>
    <p>
    To convert a Matlab M-file just enter the Scilab instruction:
    mfile2sci(file)
  </p>
    <p>
    where file is a character string giving the path name of the M-file
    mfile2sci will generate three files in the same directory
  </p>
    <dl>
      <dd>
        <b>&lt;function-name&gt;.sci</b>: the Scilab equivalent of the M-file</dd>
      <dd>
        <b>&lt;function-name&gt;.cat</b>: the Scilab help file associated to the function</dd>
      <dd>
        <b>sci_&lt;function-name&gt;.sci</b>: the Scilab function required to convert the calls to this Matlab M-file in other Matlab M-files. This function may be improved "by hand". This function is only useful for conversion not for use of translated functions.</dd>
    </dl>
    <p>
    Some functions like eye, ones, size, sum,... behave differently
    according to the dimension of their arguments. When mfile2sci cannot
    infer dimensions it replaces these function call by a call to an
    emulation function named mtlb_&lt;function_name&gt;. For efficiency these
    functions may be replaced by the proper scilab equivalent instructions.
    To get informations about replacement, enter:
    help mtlb_&lt;function_name&gt; in Scilab command window
  </p>
    <p>
    Some other functions like plot, has no straightforward équivalent in
    scilab. They are also replaced by an emulation function named
    mtlb_&lt;function_name&gt;.
  </p>
    <p>
    When translation may be incorrect or may be improved mfile2sci adds a
    comment which begins by "//!" (according to verbose-mode)
  </p>
    <p>
  When called without rhs, <tt>
        <b>mfile2sci()</b>
      </tt> launches a GUI to help to select a file/directory and options.
  </p>
    <h3>
      <font color="blue">Examples</font>
    </h3>
    <pre>

// Create a simple M-file
write(TMPDIR+'/rot90.m',['function B = rot90(A,k)'
 '[m,n] = size(A);'
 'if nargin == 1'
 '    k = 1;'
 'else'
 '    k = rem(k,4);'
 '    if k &lt; 0'
 '        k = k + 4;'
 '    end'
 'end'
 'if k == 1'
 '    A = A.'';'
 '    B = A(n:-1:1,:);'
 'elseif k == 2'
 '    B = A(m:-1:1,n:-1:1);'
 'elseif k == 3'
 '    B = A(m:-1:1,:);'
 '    B = B.'';'
 'else'
 '    B = A;'
 'end']);
// Convert it to scilab
mfile2sci(TMPDIR+'/rot90.m',TMPDIR)
// Show the new code
write(%io(2),read(TMPDIR+'/rot90.sci',-1,1,'(a)'))
// get it into scilab
getf(TMPDIR+'/rot90.sci')
// Execute it
m=rand(4,2);rot90(m,1)
 
  </pre>
    <h3>
      <font color="blue">See Also</font>
    </h3>
    <p>
      <a href="translatepaths.htm">
        <tt>
          <b>translatepaths</b>
        </tt>
      </a>,&nbsp;&nbsp;</p>
    <h3>
      <font color="blue">Authors</font>
    </h3>
    <dl>
      <dd>
        <b></b>V. Couvert</dd>
      <dd>
        <b></b>S. Steer</dd>
    </dl>
  </body>
</html>
